Skip to content

Conversation

@sideshowbarker
Copy link
Contributor

Summary

  • Refactor NotificationsView key handling for clearer control flow:

    • Check for PR/Issue actions first, then handle navigation
    • Always return after updating prView/issueSidebar (fixes tab navigation)
    • Remove redundant MarkAsRead handler (section handles it)
  • Fix PR/Issue action confirmations in Notifications view:

    • Add promptConfirmationForNotificationPR/Issue methods
    • Use footer-based confirmation instead of section confirmation
    • Add executeNotificationAction to run tasks after confirmation
    • Add closeIssue/reopenIssue helper methods

How did you test this change?

Tests included!

@sideshowbarker sideshowbarker changed the title dlvhdr/notifications fixes fix(notifications): clean up control flow and fix PR/Issue action confirmations Jan 21, 2026
…firmations

- Refactor NotificationsView key handling for clearer control flow:

  - Check for PR/Issue actions first, then handle navigation
  - Always return after updating prView/issueSidebar (fixes tab navigation)
  - Remove redundant MarkAsRead handler (section handles it)

- Fix PR/Issue action confirmations in Notifications view:

  - Add promptConfirmationForNotificationPR/Issue methods
  - Use footer-based confirmation instead of section confirmation
  - Add executeNotificationAction to run tasks after confirmation
  - Add closeIssue/reopenIssue helper methods
@sideshowbarker sideshowbarker force-pushed the dlvhdr/notifications-fixes branch from 9ff588b to d8ccb5c Compare January 21, 2026 08:46
Comment on lines +216 to +224
if m.pendingNotificationAction != "" {
if msg.String() == "y" || msg.String() == "Y" || msg.Type == tea.KeyEnter {
cmd = m.executeNotificationAction()
}
// Any other key cancels the confirmation
m.pendingNotificationAction = ""
m.footer.SetLeftSection("")
return m, cmd
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering, what's preventing the notificationsview from handling
confirmation the same as the other views? e.g. in https://github.com/dlvhdr/gh-dash/blob/main/internal/tui/components/prview/prview.go?plain=1#L100

var prCmd tea.Cmd
m.prView, prCmd = m.prView.Update(msg)
m.syncSidebar()
return m, prCmd
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use use cmds = append(cmds, prCmd) instead of return m, prCmd
since the scrolling happens in the sidebar component which gets updated here. Right now scrolling in the sidebar with Ctrl+D etc doesn't work.

}
// Sync sidebar and return issueCmd for navigation
m.syncSidebar()
return m, issueCmd
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


// Create a section identifier for the notification section
currSection := m.getCurrSection()
sid := tasks.SectionIdentifier{Id: 0, Type: notificationssection.SectionType}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use m.currSectionId

Comment on lines +1632 to +1661
switch action {
case "pr_close":
if pr := m.notificationView.GetSubjectPR(); pr != nil {
return tasks.ClosePR(m.ctx, sid, pr)
}
case "pr_reopen":
if pr := m.notificationView.GetSubjectPR(); pr != nil {
return tasks.ReopenPR(m.ctx, sid, pr)
}
case "pr_ready":
if pr := m.notificationView.GetSubjectPR(); pr != nil {
return tasks.PRReady(m.ctx, sid, pr)
}
case "pr_merge":
if pr := m.notificationView.GetSubjectPR(); pr != nil {
return tasks.MergePR(m.ctx, sid, pr)
}
case "pr_update":
if pr := m.notificationView.GetSubjectPR(); pr != nil {
return tasks.UpdatePR(m.ctx, sid, pr)
}
case "issue_close":
if issue := m.notificationView.GetSubjectIssue(); issue != nil {
return m.closeIssue(sid, issue)
}
case "issue_reopen":
if issue := m.notificationView.GetSubjectIssue(); issue != nil {
return m.reopenIssue(sid, issue)
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
switch action {
case "pr_close":
if pr := m.notificationView.GetSubjectPR(); pr != nil {
return tasks.ClosePR(m.ctx, sid, pr)
}
case "pr_reopen":
if pr := m.notificationView.GetSubjectPR(); pr != nil {
return tasks.ReopenPR(m.ctx, sid, pr)
}
case "pr_ready":
if pr := m.notificationView.GetSubjectPR(); pr != nil {
return tasks.PRReady(m.ctx, sid, pr)
}
case "pr_merge":
if pr := m.notificationView.GetSubjectPR(); pr != nil {
return tasks.MergePR(m.ctx, sid, pr)
}
case "pr_update":
if pr := m.notificationView.GetSubjectPR(); pr != nil {
return tasks.UpdatePR(m.ctx, sid, pr)
}
case "issue_close":
if issue := m.notificationView.GetSubjectIssue(); issue != nil {
return m.closeIssue(sid, issue)
}
case "issue_reopen":
if issue := m.notificationView.GetSubjectIssue(); issue != nil {
return m.reopenIssue(sid, issue)
}
}
pr := m.notificationView.GetSubjectPR()
issue := m.notificationView.GetSubjectIssue();
switch action {
case "pr_close":
if pr != nil {
return tasks.ClosePR(m.ctx, sid, pr)
}
case "pr_reopen":
if pr != nil {
return tasks.ReopenPR(m.ctx, sid, pr)
}
case "pr_ready":
if pr != nil {
return tasks.PRReady(m.ctx, sid, pr)
}
case "pr_merge":
if pr != nil {
return tasks.MergePR(m.ctx, sid, pr)
}
case "pr_update":
if pr != nil {
return tasks.UpdatePR(m.ctx, sid, pr)
}
case "issue_close":
if issue != nil {
return m.closeIssue(sid, issue)
}
case "issue_reopen":
if issue != nil {
return m.reopenIssue(sid, issue)
}
}

}

// closeIssue executes the close action for an Issue using gh CLI
func (m *Model) closeIssue(sid tasks.SectionIdentifier, issue *data.IssueData) tea.Cmd {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

// reopenIssue executes the reopen action for an Issue using gh CLI
func (m *Model) reopenIssue(sid tasks.SectionIdentifier, issue *data.IssueData) tea.Cmd {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// This is separate from section confirmation because PR/Issue actions in
// notification view need to be executed on the notification's subject PR/Issue,
// not on the notification section itself.
pendingNotificationAction string // "pr_close", "pr_merge", "issue_close", etc.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this live in the notificationsview? well if we move some logic there it
makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants